﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

namespace HoaDon
{
    public partial class BaoCao_Dev : System.Web.UI.Page
    {
        private SqlConnection appConn;
        private string ngaybd = "";
        private string ngaykt = "";
        private System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("vi-VN");
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["appConn"] != null)
            {
                appConn = (SqlConnection)Session["appConn"];
                if (!IsPostBack)
                {
                    HoaDon.Master yourMaster = (HoaDon.Master)this.Master;
                    yourMaster.ChangeTitle("Báo cáo doanh thu");
                }
                if (Session["dsBCDTBH"] != null)
                {
                    DataSet ds = Session["dsBCDTBH"] as DataSet;
                    rptBCDTBH rpt = new rptBCDTBH { DataSource = ds };
                    rpt.Ma_hang.DataBindings.Add("Text", ds, "Ma_hang");
                    rpt.Ten_hang.DataBindings.Add("Text", ds, "Ten_hang");
                    rpt.Dvt.DataBindings.Add("Text", ds, "Dvt");
                    rpt.So_luong.DataBindings.Add("Text", ds, "So_luong");
                    rpt.Gia_ban.DataBindings.Add("Text", ds, "Gia_ban");
                    rpt.Doanh_thu.DataBindings.Add("Text", ds, "Doanh_thu");
                    rpt.Gia_von.DataBindings.Add("Text", ds, "Gia_von");
                    rpt.Tien_von.DataBindings.Add("Text", ds, "Tien_von");
                    rpt.Lai.DataBindings.Add("Text", ds, "Lai");
                    if (Session["ngaybd_bc"] != null)
                        rpt.Parameters["tungay"].Value = Session["ngaybd"].ToString();
                    if (Session["ngaykt_bc"] != null)
                        rpt.Parameters["denngay"].Value = Session["ngaykt"].ToString();

					Session["Report"] = rpt;
					Response.Redirect("~\\Print.aspx");
                }
                else
                {
                    ReportToolbar1.Visible = false;
                    ReportViewer1.Visible = false;
                }
            }
            else
            {
                Response.Redirect("~\\Login.aspx");
            }
        }

    }
}
